package com.ssm.test.Sort;

public class MpSort {
    public static void main(String[] args0){
        int[] a = {4,-3,1,123};
        for(int i= 0;i < a.length-1;i++){
            for (int j = i+1 ; j < a.length ;j++){
                if(a[j]<a[i]){
                  int temp=a[j];
                  a[j]=a[i];
                  a[i]=temp;

                }
            }
        }

        for(int num:a){
            System.out.print(num+" ");
        }

        System.out.println(efsearch(a.length,0,(a.length)/2,a,1));
    }

    public static int efsearch(int begin , int end ,int middle,int[] a,int target){
        if(middle >= begin || middle <= end){
            return -1;
        }

        if(target == a[middle]){
            return middle;
        }else if (target>a[middle]){
            return efsearch(begin,end,middle+1,a,target);
        }else if (target<a[middle]){
            return efsearch(begin,end,middle-1,a,target);
        }
        return 11;
    }

}
